{% extends "popboard/base_forum.html" %}

{% block popboard_top %}
<h1>Forums</h1>
{% endblock %}

{% block popboard_main %}
    <p class="subtitle"><a href="{% url popboard-feed "latest" %}"><img src="{{ MEDIA_URL }}{{ POPBOARD_MEDIA_PREFIX }}images/feed-icon.png" /></a> {{ topic_count }} topics, {{ post_count }} posts </p>
    
    {% if cat_list %}
      <table class="wide forums" border="0" cellpadding="0" cellspacing="0">
    <tbody><tr>
      <th class="la" colspan="3" width="70%">Forum</th>
      <th class="la" colspan="1" width="30%">Last Post</th>
    </tr>
        {% for category in cat_list %}
          <tr>
            <td class="vat c1">
              <img alt="Comment" class="icon grey" src="{{ MEDIA_URL }}{{ POPBOARD_MEDIA_PREFIX }}images/comment.gif" title="No recent activity" />

            </td>
            <td class="c2 vat">
              <a href="{{ category.get_absolute_url }}" class="title">{{ category.name }}</a>
              <div class="posts">
                {{ category.thread_count }}  topic(s), 
                {{ category.post_count }} post(s)
              </div>
              <p class="desc">{{ category.description }}</p>
            </td>
            <td class="c3">
            </td>
            {% if category.thread_set.all %}
            <td class="inv lp">
                {% with category.thread_set.latest as most_recent_thread %}
                    <span class="time">{{ most_recent_thread.modified|timesince }} ago</span><br />
                    <a href="{{ most_recent_thread.get_absolute_url }}">{{ most_recent_thread.title }}</a> by {{ most_recent_thread.user.username }}
                {% endwith %}
                  </td>
            {% else %}
            <td class="inv lp">
                  </td>
            {% endif %}
          </tr>          
        {% endfor %}
        </tbody></table>
        <p>
          <a href="{% url popboard-post-index %}">Recent posts</a>
        </p>
    {% else %}
        <p>No categories are available.</p>
    {% endif %}
    
{% endblock %}
